package com.ruibang.glass.produce.controller.yc;

import com.ruibang.glass.produce.domain.req.ProcessAbnormalityReq;
import com.ruibang.glass.produce.entity.ProcessAbnormality;
import com.ruibang.glass.produce.service.ProcessAbnormalityService;
import com.teaming.cloud.framework2.common.model.ResultBody;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

/**
 * @Author: songJinKang
 * @CreateTime: 2023-11-22  20:15
 * @Description: TODO
 * @Version: 1.0
 */


@Api(tags = "工序异常记录(全部工序异常)")
@RestController
@RequestMapping("/api/glass/produce/yl/abnormality")
public class ProcessAbnormalityController {

    @Autowired
    private ProcessAbnormalityService processAbnormalityService;

    @PostMapping("/add")
    @ApiOperation(value = "新增", response = ResultBody.class)
    public ResultBody add(@RequestBody @Valid ProcessAbnormality processAbnormality) {
        return processAbnormalityService.add(processAbnormality);
    }

    @PutMapping("/edit")
    @ApiOperation(value = "修改", response = ResultBody.class)
    public ResultBody edit(@RequestBody @Valid ProcessAbnormality processAbnormality) {
        return processAbnormalityService.edit(processAbnormality);
    }

    @DeleteMapping("/deleteById/{id}")
    @ApiOperation(value = "删除异常", response = ResultBody.class)
    public ResultBody deleteById(@PathVariable String id) {
        processAbnormalityService.deleteById(id);
        return ResultBody.success();
    }

    @PostMapping("/queryAbnormality")
    @ApiOperation(value = "查询工序异常", response = ResultBody.class)
    public ResultBody queryAbnormality(@RequestBody ProcessAbnormalityReq processAbnormalityReq) {
        return ResultBody.success(processAbnormalityService.queryAbnormality(processAbnormalityReq));
    }
}
